package o;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Looper;
import android.os.Parcel;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import androidx.annotation.Nullable;
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
import java.io.Closeable;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.Formatter;
import java.util.List;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.checkerframework.checker.nullness.qual.EnsuresNonNull;

public final class anr {
    private static final int[] ʻ = new int[]{0, 79764919, 159529838, 222504665, 319059676, 398814059, 445009330, 507990021, 638119352, 583659535, 797628118, 726387553, 890018660, 835552979, 1015980042, 944750013, 1276238704, 1221641927, 1167319070, 1095957929, 1595256236, 1540665371, 1452775106, 1381403509, 1780037320, 1859660671, 1671105958, 1733955601, 2031960084, 2111593891, 1889500026, 1952343757, -1742489888, -1662866601, -1851683442, -1788833735, -1960329156, -1880695413, -2103051438, -2040207643, -1104454824, -1159051537, -1213636554, -1284997759, -1389417084, -1444007885, -1532160278, -1603531939, -734892656, -789352409, -575645954, -646886583, -952755380, -1007220997, -827056094, -898286187, -231047128, -151282273, -71779514, -8804623, -515967244, -436212925, -390279782, -327299027, 881225847, 809987520, 1023691545, 969234094, 662832811, 591600412, 771767749, 717299826, 311336399, 374308984, 453813921, 533576470, 25881363, 88864420, 134795389, 214552010, 2023205639, 2086057648, 1897238633, 1976864222, 1804852699, 1867694188, 1645340341, 1724971778, 1587496639, 1516133128, 1461550545, 1406951526, 1302016099, 1230646740, 1142491917, 1087903418, -1398421865, -1469785312, -1524105735, -1578704818, -1079922613, -1151291908, -1239184603, -1293773166, -1968362705, -1905510760, -2094067647, -2014441994, -1716953613, -1654112188, -1876203875, -1796572374, -525066777, -462094256, -382327159, -302564546, -206542021, -143559028, -97365931, -17609246, -960696225, -1031934488, -817968335, -872425850, -709327229, -780559564, -600130067, -654598054, 1762451694, 1842216281, 1619975040, 1682949687, 2047383090, 2127137669, 1938468188, 2001449195, 1325665622, 1271206113, 1183200824, 1111960463, 1543535498, 1489069629, 1434599652, 1363369299, 622672798, 568075817, 748617968, 677256519, 907627842, 853037301, 1067152940, 995781531, 51762726, 131386257, 177728840, 240578815, 269590778, 349224269, 429104020, 491947555, -248556018, -168932423, -122852000, -60002089, -500490030, -420856475, -341238852, -278395381, -685261898, -739858943, -559578920, -630940305, -1004286614, -1058877219, -845023740, -916395085, -1119974018, -1174433591, -1262701040, -1333941337, -1371866206, -1426332139, -1481064244, -1552294533, -1690935098, -1611170447, -1833673816, -1770699233, -2009983462, -1930228819, -2119160460, -2056179517, 1569362073, 1498123566, 1409854455, 1355396672, 1317987909, 1246755826, 1192025387, 1137557660, 2072149281, 2135122070, 1912620623, 1992383480, 1753615357, 1816598090, 1627664531, 1707420964, 295390185, 358241886, 404320391, 483945776, 43990325, 106832002, 186451547, 266083308, 932423249, 861060070, 1041341759, 986742920, 613929101, 542559546, 756411363, 701822548, -978770311, -1050133554, -869589737, -924188512, -693284699, -764654318, -550540341, -605129092, -475935807, -413084042, -366743377, -287118056, -257573603, -194731862, -114850189, -35218492, -1984365303, -1921392450, -2143631769, -2063868976, -1698919467, -1635936670, -1824608069, -1744851700, -1347415887, -1418654458, -1506661409, -1561119128, -1129027987, -1200260134, -1254728445, -1309196108};
    private static final Pattern ʼ = Pattern.compile("^(-)?P(([0-9]*)Y)?(([0-9]*)M)?(([0-9]*)D)?(T(([0-9]*)H)?(([0-9]*)M)?(([0-9.]*)S)?)?$");
    public static final byte[] ʽ = new byte[0];
    public static final String ˊ = Build.MODEL;
    public static final int ˋ = VERSION.SDK_INT;
    public static final String ˎ = Build.DEVICE;
    public static final String ˏ = Build.MANUFACTURER;
    public static final String ॱ = (ˎ + ", " + ˊ + ", " + ˏ + ", " + ˋ);
    private static final Pattern ॱॱ = Pattern.compile("(\\d\\d\\d\\d)\\-(\\d\\d)\\-(\\d\\d)[Tt](\\d\\d):(\\d\\d):(\\d\\d)([\\.,](\\d+))?([Zz]|((\\+|\\-)(\\d?\\d):?(\\d\\d)))?");
    private static final Pattern ᐝ = Pattern.compile("%([A-Fa-f0-9]{2})");

    public static ComponentName ˊ(Context context, Intent intent) {
        if (ˋ >= 26) {
            return context.startForegroundService(intent);
        }
        return context.startService(intent);
    }

    public static boolean ˏ(Uri uri) {
        CharSequence scheme = uri.getScheme();
        return TextUtils.isEmpty(scheme) || "file".equals(scheme);
    }

    public static boolean ˎ(@Nullable Object obj, @Nullable Object obj2) {
        if (obj == null) {
            return obj2 == null;
        } else {
            return obj.equals(obj2);
        }
    }

    @EnsuresNonNull({"#1"})
    public static <T> T ˎ(@Nullable T t) {
        return t;
    }

    @EnsuresNonNull({"#1"})
    public static <T> T[] ॱ(T[] tArr) {
        return tArr;
    }

    public static <T> T[] ॱ(T[] tArr, int i) {
        amm.ˊ(i <= tArr.length);
        return Arrays.copyOf(tArr, i);
    }

    public static Handler ˏ(Looper looper, Callback callback) {
        return new Handler(looper, callback);
    }

    public static Looper ˎ() {
        Looper myLooper = Looper.myLooper();
        return myLooper != null ? myLooper : Looper.getMainLooper();
    }

    public static ExecutorService ॱ(String str) {
        return Executors.newSingleThreadExecutor(new ant(str));
    }

    public static void ˋ(alj o_alj) {
        if (o_alj != null) {
            try {
                o_alj.ॱ();
            } catch (IOException e) {
            }
        }
    }

    public static void ॱ(Closeable closeable) {
        if (closeable != null) {
            try {
                closeable.close();
            } catch (IOException e) {
            }
        }
    }

    public static boolean ˋ(Parcel parcel) {
        return parcel.readInt() != 0;
    }

    public static void ˎ(Parcel parcel, boolean z) {
        parcel.writeInt(z ? 1 : 0);
    }

    @Nullable
    public static String ˋ(@Nullable String str) {
        if (str == null) {
            return null;
        }
        try {
            return new Locale(str).getISO3Language();
        } catch (MissingResourceException e) {
            return ˎ(str);
        }
    }

    public static String ॱ(byte[] bArr) {
        return new String(bArr, Charset.forName("UTF-8"));
    }

    public static String ˊ(byte[] bArr, int i, int i2) {
        return new String(bArr, i, i2, Charset.forName("UTF-8"));
    }

    public static byte[] ˊ(String str) {
        return str.getBytes(Charset.forName("UTF-8"));
    }

    public static String[] ˎ(String str, String str2) {
        return str.split(str2, -1);
    }

    public static String[] ˊ(String str, String str2) {
        return str.split(str2, 2);
    }

    public static boolean ˎ(int i) {
        return i == 10 || i == 13;
    }

    public static String ˎ(String str) {
        return str == null ? str : str.toLowerCase(Locale.US);
    }

    public static String ˏ(String str) {
        return str == null ? str : str.toUpperCase(Locale.US);
    }

    public static String ˏ(String str, Object... objArr) {
        return String.format(Locale.US, str, objArr);
    }

    public static int ˎ(int i, int i2) {
        return ((i + i2) - 1) / i2;
    }

    public static int ॱ(int i, int i2, int i3) {
        return Math.max(i2, Math.min(i, i3));
    }

    public static long ˎ(long j, long j2, long j3) {
        return Math.max(j2, Math.min(j, j3));
    }

    public static float ˋ(float f, float f2, float f3) {
        return Math.max(f2, Math.min(f, f3));
    }

    public static long ˊ(long j, long j2, long j3) {
        long j4 = j + j2;
        return ((j ^ j4) & (j2 ^ j4)) < 0 ? j3 : j4;
    }

    public static long ˏ(long j, long j2, long j3) {
        long j4 = j - j2;
        return ((j ^ j2) & (j ^ j4)) < 0 ? j3 : j4;
    }

    public static int ˊ(long[] jArr, long j, boolean z, boolean z2) {
        int binarySearch = Arrays.binarySearch(jArr, j);
        if (binarySearch < 0) {
            binarySearch = -(binarySearch + 2);
        } else {
            do {
                binarySearch--;
                if (binarySearch < 0) {
                    break;
                }
            } while (jArr[binarySearch] == j);
            if (z) {
                binarySearch++;
            }
        }
        return z2 ? Math.max(0, binarySearch) : binarySearch;
    }

    public static int ॱ(long[] jArr, long j, boolean z, boolean z2) {
        int binarySearch = Arrays.binarySearch(jArr, j);
        if (binarySearch < 0) {
            binarySearch ^= -1;
        } else {
            do {
                binarySearch++;
                if (binarySearch >= jArr.length) {
                    break;
                }
            } while (jArr[binarySearch] == j);
            if (z) {
                binarySearch--;
            }
        }
        return z2 ? Math.min(jArr.length - 1, binarySearch) : binarySearch;
    }

    public static int ˏ(long j, long j2) {
        if (j < j2) {
            return -1;
        }
        return j == j2 ? 0 : 1;
    }

    public static long ॱ(long j, long j2, long j3) {
        if (j3 >= j2 && j3 % j2 == 0) {
            return j / (j3 / j2);
        }
        if (j3 >= j2 || j2 % j3 != 0) {
            return (long) ((((double) j2) / ((double) j3)) * ((double) j));
        }
        return (j2 / j3) * j;
    }

    public static void ˊ(long[] jArr, long j, long j2) {
        int i = 0;
        long j3;
        if (j2 >= j && j2 % j == 0) {
            j3 = j2 / j;
            while (i < jArr.length) {
                jArr[i] = jArr[i] / j3;
                i++;
            }
        } else if (j2 >= j || j % j2 != 0) {
            double d = ((double) j) / ((double) j2);
            while (i < jArr.length) {
                jArr[i] = (long) (((double) jArr[i]) * d);
                i++;
            }
        } else {
            j3 = j / j2;
            while (i < jArr.length) {
                jArr[i] = jArr[i] * j3;
                i++;
            }
        }
    }

    public static long ˏ(long j, float f) {
        return f == 1.0f ? j : Math.round(((double) j) * ((double) f));
    }

    public static long ˊ(long j, float f) {
        return f == 1.0f ? j : Math.round(((double) j) / ((double) f));
    }

    public static long ˎ(long j, abv o_abv, long j2, long j3) {
        if (abv.ˊ.equals(o_abv)) {
            return j;
        }
        long ˏ = ˏ(j, o_abv.ʻ, Long.MIN_VALUE);
        long ˊ = ˊ(j, o_abv.ᐝ, Long.MAX_VALUE);
        Object obj = (ˏ > j2 || j2 > ˊ) ? null : 1;
        Object obj2 = (ˏ > j3 || j3 > ˊ) ? null : 1;
        if (obj == null || obj2 == null) {
            if (obj != null) {
                return j2;
            }
            if (obj2 != null) {
                return j3;
            }
            return ˏ;
        } else if (Math.abs(j2 - j) > Math.abs(j3 - j)) {
            return j3;
        } else {
            return j2;
        }
    }

    public static int[] ˎ(List<Integer> list) {
        if (list == null) {
            return null;
        }
        int size = list.size();
        int[] iArr = new int[size];
        for (int i = 0; i < size; i++) {
            iArr[i] = ((Integer) list.get(i)).intValue();
        }
        return iArr;
    }

    public static int ᐝ(String str) {
        boolean z;
        int i = 0;
        int length = str.length();
        if (length <= 4) {
            z = true;
        } else {
            z = false;
        }
        amm.ˊ(z);
        int i2 = 0;
        while (i < length) {
            i2 = (i2 << 8) | str.charAt(i);
            i++;
        }
        return i2;
    }

    public static byte[] ʼ(String str) {
        byte[] bArr = new byte[(str.length() / 2)];
        for (int i = 0; i < bArr.length; i++) {
            int i2 = i * 2;
            bArr[i] = (byte) (Character.digit(str.charAt(i2 + 1), 16) + (Character.digit(str.charAt(i2), 16) << 4));
        }
        return bArr;
    }

    public static String ˊ(Object[] objArr) {
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < objArr.length; i++) {
            stringBuilder.append(objArr[i].getClass().getSimpleName());
            if (i < objArr.length - 1) {
                stringBuilder.append(", ");
            }
        }
        return stringBuilder.toString();
    }

    public static String ॱ(Context context, String str) {
        String str2;
        try {
            str2 = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
        } catch (NameNotFoundException e) {
            str2 = "?";
        }
        return str + "/" + str2 + " (Linux;Android " + VERSION.RELEASE + ") " + "ExoPlayerLib/2.9.6";
    }

    public static int ˊ(int i) {
        switch (i) {
            case 8:
                return 3;
            case 16:
                return 2;
            case 24:
                return Integer.MIN_VALUE;
            case 32:
                return 1073741824;
            default:
                return 0;
        }
    }

    public static boolean ˋ(int i) {
        return i == 3 || i == 2 || i == Integer.MIN_VALUE || i == 1073741824 || i == 4;
    }

    public static boolean ॱ(int i) {
        return i == Integer.MIN_VALUE || i == 1073741824;
    }

    public static int ˏ(int i) {
        switch (i) {
            case 1:
                return 4;
            case 2:
                return 12;
            case 3:
                return 28;
            case 4:
                return 204;
            case 5:
                return 220;
            case 6:
                return 252;
            case 7:
                return 1276;
            case 8:
                if (ˋ >= 23 || ˋ >= 21) {
                    return 6396;
                }
                return 0;
            default:
                return 0;
        }
    }

    public static int ˊ(int i, int i2) {
        switch (i) {
            case Integer.MIN_VALUE:
                return i2 * 3;
            case 2:
                return i2 * 2;
            case 3:
                return i2;
            case 4:
            case 1073741824:
                return i2 * 4;
            default:
                throw new IllegalArgumentException();
        }
    }

    public static int ʻ(int i) {
        switch (i) {
            case 2:
                return 0;
            case 3:
                return 8;
            case 4:
                return 4;
            case 5:
            case 7:
            case 8:
            case 9:
            case 10:
                return 5;
            case 6:
                return 2;
            case 13:
                return 1;
            default:
                return 3;
        }
    }

    public static String ˊ(StringBuilder stringBuilder, Formatter formatter, long j) {
        if (j == -9223372036854775807L) {
            j = 0;
        }
        long j2 = (500 + j) / 1000;
        long j3 = j2 % 60;
        long j4 = (j2 / 60) % 60;
        j2 /= 3600;
        stringBuilder.setLength(0);
        if (j2 > 0) {
            return formatter.format("%d:%02d:%02d", new Object[]{Long.valueOf(j2), Long.valueOf(j4), Long.valueOf(j3)}).toString();
        }
        return formatter.format("%02d:%02d", new Object[]{Long.valueOf(j4), Long.valueOf(j3)}).toString();
    }

    public static int ᐝ(int i) {
        switch (i) {
            case 0:
                return 16777216;
            case 1:
                return 3538944;
            case 2:
                return 13107200;
            case 3:
            case 4:
            case 5:
                return WXMediaMessage.MINI_PROGRAM__THUMB_LENGHT;
            case 6:
                return 0;
            default:
                throw new IllegalArgumentException();
        }
    }

    @Nullable
    public static String ॱॱ(String str) {
        int i;
        int length = str.length();
        int i2 = 0;
        for (i = 0; i < length; i++) {
            if (str.charAt(i) == '%') {
                i2++;
            }
        }
        if (i2 == 0) {
            return str;
        }
        i = length - (i2 * 2);
        StringBuilder stringBuilder = new StringBuilder(i);
        Matcher matcher = ᐝ.matcher(str);
        i2 = 0;
        for (int i3 = i2; i3 > 0 && matcher.find(); i3--) {
            stringBuilder.append(str, i2, matcher.start()).append((char) Integer.parseInt(matcher.group(1), 16));
            i2 = matcher.end();
        }
        if (i2 < length) {
            stringBuilder.append(str, i2, length);
        }
        if (stringBuilder.length() != i) {
            return null;
        }
        return stringBuilder.toString();
    }

    public static void ॱ(Throwable th) {
        ˎ(th);
    }

    private static <T extends Throwable> void ˎ(Throwable th) throws Throwable {
        throw th;
    }

    public static int ˎ(byte[] bArr, int i, int i2, int i3) {
        while (i < i2) {
            i3 = (i3 << 8) ^ ʻ[((i3 >>> 24) ^ (bArr[i] & 255)) & 255];
            i++;
        }
        return i3;
    }

    public static int ॱ(@Nullable Context context) {
        if (context == null) {
            return 0;
        }
        try {
            ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
            if (connectivityManager == null) {
                return 0;
            }
            NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
            if (activeNetworkInfo == null || !activeNetworkInfo.isConnected()) {
                return 1;
            }
            switch (activeNetworkInfo.getType()) {
                case 0:
                case 4:
                case 5:
                    return ˋ(activeNetworkInfo);
                case 1:
                    return 2;
                case 6:
                    return 5;
                case 9:
                    return 7;
                default:
                    return 8;
            }
        } catch (SecurityException e) {
            return 0;
        }
    }

    public static String ˏ(@Nullable Context context) {
        if (context != null) {
            TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
            if (telephonyManager != null) {
                String networkCountryIso = telephonyManager.getNetworkCountryIso();
                if (!TextUtils.isEmpty(networkCountryIso)) {
                    return ˏ(networkCountryIso);
                }
            }
        }
        return ˏ(Locale.getDefault().getCountry());
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static boolean ॱ(o.anc r5, o.anc r6, @androidx.annotation.Nullable java.util.zip.Inflater r7) {
        /*
        r0 = 0;
        r1 = r5.ˊ();
        if (r1 > 0) goto L_0x0008;
    L_0x0007:
        return r0;
    L_0x0008:
        r1 = r6.ˏ;
        r2 = r1.length;
        r3 = r5.ˊ();
        if (r2 >= r3) goto L_0x0019;
    L_0x0011:
        r1 = r5.ˊ();
        r1 = r1 * 2;
        r1 = new byte[r1];
    L_0x0019:
        if (r7 != 0) goto L_0x0020;
    L_0x001b:
        r7 = new java.util.zip.Inflater;
        r7.<init>();
    L_0x0020:
        r2 = r5.ˏ;
        r3 = r5.ˋ();
        r4 = r5.ˊ();
        r7.setInput(r2, r3, r4);
        r2 = r1;
        r1 = r0;
    L_0x002f:
        r3 = r2.length;	 Catch:{ DataFormatException -> 0x005f, all -> 0x0064 }
        r3 = r3 - r1;
        r3 = r7.inflate(r2, r1, r3);	 Catch:{ DataFormatException -> 0x005f, all -> 0x0064 }
        r1 = r1 + r3;
        r3 = r7.finished();	 Catch:{ DataFormatException -> 0x005f, all -> 0x0064 }
        if (r3 == 0) goto L_0x0044;
    L_0x003c:
        r6.ॱ(r2, r1);	 Catch:{ DataFormatException -> 0x005f, all -> 0x0064 }
        r0 = 1;
        r7.reset();
        goto L_0x0007;
    L_0x0044:
        r3 = r7.needsDictionary();	 Catch:{ DataFormatException -> 0x005f, all -> 0x0064 }
        if (r3 != 0) goto L_0x0050;
    L_0x004a:
        r3 = r7.needsInput();	 Catch:{ DataFormatException -> 0x005f, all -> 0x0064 }
        if (r3 == 0) goto L_0x0054;
    L_0x0050:
        r7.reset();
        goto L_0x0007;
    L_0x0054:
        r3 = r2.length;	 Catch:{ DataFormatException -> 0x005f, all -> 0x0064 }
        if (r1 != r3) goto L_0x002f;
    L_0x0057:
        r3 = r2.length;	 Catch:{ DataFormatException -> 0x005f, all -> 0x0064 }
        r3 = r3 * 2;
        r2 = java.util.Arrays.copyOf(r2, r3);	 Catch:{ DataFormatException -> 0x005f, all -> 0x0064 }
        goto L_0x002f;
    L_0x005f:
        r1 = move-exception;
        r7.reset();
        goto L_0x0007;
    L_0x0064:
        r0 = move-exception;
        r7.reset();
        throw r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: o.anr.ॱ(o.anc, o.anc, java.util.zip.Inflater):boolean");
    }

    private static int ˋ(NetworkInfo networkInfo) {
        switch (networkInfo.getSubtype()) {
            case 1:
            case 2:
                return 3;
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 14:
            case 15:
            case 17:
                return 4;
            case 13:
                return 5;
            case 18:
                return 2;
            default:
                return 6;
        }
    }
}
